/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package be.ugent.medirem.logic;

import be.ugent.medirem.persistence.entity.details.ConsultationDetails;
import be.ugent.medirem.persistence.entity.details.GpDetails;
import be.ugent.medirem.persistence.entity.details.LocationDetails;
import be.ugent.medirem.persistence.entity.details.PatientDetails;
import be.ugent.medirem.persistence.entity.values.LocationValues;
import be.ugent.medirem.persistence.entity.values.PatientValues;
import be.ugent.medirem.persistence.exception.EntityNotFoundException;
import java.util.List;
import javax.annotation.security.RolesAllowed;
import javax.ejb.Remote;

/**
 *
 * @author Thomas Roelens
 */
@Remote
public interface PatientRemote {

    @RolesAllowed("gp")
    Long createPatient(PatientValues values);

    @RolesAllowed({"gp","patient"})
    PatientDetails getPatientDetails(Long patientId) throws EntityNotFoundException, IllegalArgumentException;

    @RolesAllowed({"gp","patient"})
    LocationDetails getLocationDetails(Long patientId) throws EntityNotFoundException, IllegalArgumentException;

    @RolesAllowed("gp")
    List<PatientDetails> getAllPatients();

    @RolesAllowed("gp")
    void removePatient(Long patientId) throws EntityNotFoundException, IllegalArgumentException;

    @RolesAllowed({"gp","patient"})
    void updatePatient(PatientValues details) throws EntityNotFoundException, IllegalArgumentException;

    /**
     * Update (or add) a new Location to a patient
     * @param patientId The id of the patient
     * @param locationIdToUpdate Provide an id if you want to update the location, null if you are creating a new location
     * @param locationDetails The location information
     * @throws EntityNotFoundException
     * @throws IllegalArgumentException
     */
    @RolesAllowed({"patient"})
    void updatePatient(Long patientId, Long locationIdToUpdate, LocationValues locationDetails) throws EntityNotFoundException, IllegalArgumentException;

    @RolesAllowed({"gp", "patient"})
    void updatePatientPassword(Long id, String oldPassword, String newPassword) throws EntityNotFoundException, IllegalArgumentException;

    @RolesAllowed({"patient"})
    Long getPatientId(String username) throws IllegalArgumentException;

    // Todo: only data that is public should be shown
    @RolesAllowed({"gp","patient"})
    List<GpDetails> getGpPublicDetails(Long patientId);

    @RolesAllowed("gp")
    PatientDetails searchPatientsBySocialSecurityNumber(String number);

    @RolesAllowed("patient")
    List<ConsultationDetails> getConsultations(Long id);
}
